﻿using System;
using System.Collections.Generic;
using Logic;

namespace VotanetWebSite.Acceso_Administrador
{
    public partial class Reportes : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["reporte"] != null)
            {
                ShowChartSex();
                ShowChartCivilStatus();
                ShowChartGroups();
                ShowAgeChart();
                ShowComunneChart();
            }

            else
            {
                Response.RedirectPermanent("Administracion_Votacion.aspx");
            }

        }

        private void ShowChartSex()
        {
            Dictionary<string, int> dic = new ReportsLogic().GetSexGlobalVotinReportLogic(1);
            Chart1.ChartAreas["ChartAreaSex"].AxisX.Interval = 1;
            Chart1.Series["ChartSEx"].Points.DataBindXY(dic, "key", dic, "value");
        }

        private void ShowChartCivilStatus()
        {
            Dictionary<string, int> masterDic = new ReportsLogic().GetCivilStatusGlobalVotinReportLogic(2);
            ChartCivilStatus.ChartAreas["ChartAreaCivilStatus"].AxisX.Interval = 1;
            ChartCivilStatus.Series["ChartSerieCivilStatus"].Points.DataBindXY(masterDic, "key", masterDic, "value");

        }



        private void ShowChartGroups()
        {
            Dictionary<string, int> masterDic = new ReportsLogic().GetGroupGlobalVotinReportLogic(3);
            ChartGroup.ChartAreas["ChartAreaGroup"].AxisX.Interval = 1;
            ChartGroup.Series["ChartSerieGroup"].Points.DataBindXY(masterDic, "key", masterDic, "value");

        }

        private void ShowAgeChart()
        {
            Dictionary<string, int> masterDic = new ReportsLogic().GetAgeGlobalVotinReportLogic();
            ChartAge.ChartAreas["ChartAreaAge"].AxisX.Interval = 1;
            ChartAge.Series["ChartSerieAge"].Points.DataBindXY(masterDic, "key", masterDic, "value");
        }

        private void ShowComunneChart()
        {
            Dictionary<string, int> masterDic = new ReportsLogic().GetComunneGlobalVotinReportLogic(4);
            ChartComunne.ChartAreas["ChartAreaComunne"].AxisX.Interval = 1;
            ChartComunne.Series["ChartSerieComunne"].Points.DataBindXY(masterDic, "key", masterDic, "value");
            
        }

        protected void BtnLogout_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            Response.RedirectPermanent("~/Seguridad/Logout.aspx");
        }
    }
}